[BUG] fix axis label overlap in plot_volume_source_estimates by using draw_idle()#13708
[BUG] fix axis label overlap in plot_volume_source_estimates by using draw_idle()#13708Famous077 wants to merge 8 commits intomne-tools:mainfrom
Conversation
for more information, see https://pre-commit.ci
|
All tests in mne/viz/tests/test_3d_mpl.py pass locally. |
|
@Famous077 looks good! Did you use AI at all during the development of this PR, and if so, can you explain how / to what extent? |
Yes, I did use AI. happy to be transparent about it. But, I used it as a research and debugging aid, mainly in areas that would have been too time-consuming to dig through alone, such as understanding the difference between canvas.draw() and canvas.draw_idle(), why calling draw() synchronously after every event causes blitting artifacts with nilearn, and clearing doubts about specific lines of code, but actual diagnosis, implementation, and testing were entirely my own. |
drammock
left a comment
There was a problem hiding this comment.
on second look:
- the linked issue that will be auto-closed by this is unrelated (it's another of your own PRs)
- can you link to an example in the docs where this label overlap is happening?
- can you modify that example/tutorial that uses plot_volume_source_estimates (a linebreak/whitespace change is enough) so that the CI will run it, and we can see that the label overlap is fixed?
|
Hi @drammock , Thank you for the review. I have addressed the following: -Removed the incorrect issue reference from the PR description Regarding linking to an example in the docs , I searched through all examples and tutorials but could not find one that directly calls plot_volume_source_estimates. Could you point me to the specific example you had in mind so I can add a whitespace change to trigger CI to run it? Thank you for your guidance |
|
However, the PR description is still (wrongly) linking to #13700 (which isn't related to |
|
Hi @drammock , After further investigation, I can confirm the bug is reproducible locally Here is a screenshot showing the bug: I've tried:
Could you point me in the right direction for the correct fix? Is this indeed a nilearn compatibility issue? |
I don't know off hand (and would be surprised if @drammock did either), it will likely require some investigation and testing out of other possible solutions. Possibly a |
Hi @larsoner , what should i do to resolve this issue? Any suggestions . |
did you try the prior suggestion:
|
Okay. After implementation I will reach out to you. |

This PR addresses axis label overlap and rendering artifacts observed
when navigating through time in
plot_volume_source_estimates()byreplacing
canvas.draw()withcanvas.draw_idle().Problem
When plotting volume source estimates, axis labels were mangled and
overlapping on the colorbar and y-axis of the time series plot.
The MRI and colorbar also appeared shifted relative to the black background.
Root Cause
canvas.draw()was being called after each click/keypress event in_press()and_onclick(), causing blitting artifacts when combinedwith nilearn's plotting functions.
Fix
Replaced
canvas.draw()withcanvas.draw_idle()in both_press()and
_onclick()functions inmne/viz/_3d.py. This lets matplotlibschedule the redraw properly and avoids the rendering artifacts.
Changes
mne/viz/_3d.py:canvas.draw()→canvas.draw_idle()in_press()and_onclick()doc/changes/dev/13700.bugfix.rst: changelog entrydoc/changes/names.inc: added contributor name